Back to course home
0% completed
Vote For New Content
Amazon Hard Problems
Constrained Subsequence Sum (hard)
Solution: Constrained Subsequence Sum
Number of Valid Subarrays (hard)
Solution: Number of Valid Subarrays
Count Vowels Permutation (hard)
Solution: Count Vowels Permutation
Concatenated Words (hard)
Solution: Concatenated Words
Minimum Replacements to Sort the Array (hard)
Solution: Minimum Replacements to Sort the Array
Count All Valid Pickup and Delivery Options (hard)
Solution: Count All Valid Pickup and Delivery Options
Length of the Longest Valid Substring (hard)
Solution: Length of the Longest Valid Substring
Count Array Pairs Divisible by K (hard)
Solution: Count Array Pairs Divisible by K
Word Ladder (hard)
Solution: Word Ladder
Path with Maximum Sum (hard)
Solution: Path with Maximum Sum
The kth Factor of n (medium)
Problem Statement
Given two integers, n and k, return the kth smallest factor of n. If n has fewer factors than k factors, return -1.
A factor of a number is an integer that can divide that number without leaving a remainder.
Examples
-
Example 1:
- Input:
n = 12,k = 5 - Expected Output:
6 - Justification: The factors of 12 are 1, 2, 3, 4, 6, and 12. The fifth smallest factor is 6.
- Input:
-
Example 2:
- Input:
n = 17,k = 2 - Expected Output:
17 - Justification: The factors of 17 are 1 and 17, since 17 is a prime number. The second smallest factor is 17.
- Input:
-
Example 3:
- Input:
n = 10,k = 5 - Expected Output:
-1 - Justification: The factors of 10 are 1, 2, and 5. 10 has only 3 factors, so the answer is
-1.
- Input:
Try it yourself
Try solving this question here:
Java
. . . .
Solution: Deepest Leaves Sum
Solution: The kth Factor of n
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself